import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { MagicWeaponItemData } from "../MagicWeaponItemData";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../../extend/language/Language";
import { ColorConfig } from "../../../resource/ColorConfig";
import { EPlayerItemPosType } from "../../../../../Message/Public/EPlayerItemPosType";
import { DisplayUtil } from "../../../../common/DisplayUtil";
import { LoaderManager } from "../../../../../com/gengine/resource/LoaderManager";
import { ObjCreate } from "../../common/ObjCreate";
import { ImageInfo } from "../../../../../com/gengine/resource/info/ImageInfo";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { BaseItem } from "../../common/BaseItem";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
type int = number;
//class MagicWeaponItemRenderer
    
    export  class MagicWeaponItemRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            setSize(125, 50);
            this.init();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            var loc1=arg1 as MagicWeaponItemData;
            if (loc1 && loc1.itemData) 
            {
                if (!(loc1.name == null) && !(loc1.name == "")) 
                {
                    this.name = loc1.name;
                }
                else 
                {
                    this.name = "MagicWeaponItemRenderer" + (Math.random() * 10000000).toString() + (Math.random() * 10000000).toString();
                }
                this._baseItem.itemData = loc1.itemData;
                if (loc1.isSelect) 
                {
                    this.filters = [FilterConst.colorFilter2];
                    this.enabled = false;
                }
                else 
                {
                    this.filters = [];
                    this.enabled = true;
                }
                if (loc1.itemData.isHasIdentify()) 
                {
                    this._score.htmlText = HTMLUtil.addColor(Language.getStringByParam(27673, loc1.itemData.magicWeaponScore), "#ffff00");
                }
                else 
                {
                    this._score.htmlText = HTMLUtil.addColor(Language.getString(27672), "#F54a4a");
                }
                this.posType = loc1.itemData.posType;
                this._name.htmlText = HTMLUtil.addColor(loc1.itemData.name, ColorConfig.instance.getItemColor(loc1.itemData.color).color);
            }
            return;
        }

        /* internal  */set posType(arg1: int)
        {
            if (arg1 != EPlayerItemPosType._EPlayerItemPosTypeRole) 
            {
                DisplayUtil.removeMe(this._wearBg);
            }
            else 
            {
                if (this._wearBg == null) 
                {
                    this._wearBg = new Object /* flash.display.Bitmap */();
                    LoaderManager.instance.load("Equipmet_Equiped.png", this.onWearBgLoader);
                }
                ObjCreate.setObjAttri(this._wearBg, 80, 18, -1, -1, this);
            }
            return;
        }

        /* internal  */onWearBgLoader(arg1: ImageInfo): void
        {
            this._wearBg.bitmapData = arg1.bitmapData;
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(0, 0, 128, 40, this, ImagesConst.DisabledBg);
            this._name = ObjCreate.createGTextField("", 40, 1, 85, 25, this, GlobalStyle.textFormat6);
            this._score = ObjCreate.createGTextField("", 40, 20, 50, 25, this, GlobalStyle.textFormat6);
            ObjCreate.createBitmap(ImagesConst.PackItemBg, 0, 0, this);
            this._baseItem = new BaseItem();
            this._baseItem.isShowLock = true;
            ObjCreate.setObjAttri(this._baseItem, 3, 3, 32, 32, this);
            return;
        }

        /* internal */ /* var */_baseItem: BaseItem;

        /* internal */ /* var */_name: GTextFiled;

        /* internal */ /* var */_score: GTextFiled;

        /* internal */ /* var */_wearBg: Object /* flash.display.Bitmap */;
    }
